//
//  FirstOpenViewController.m
//  GreenZone
//
//  Created by student on 15/6/15.
//  Copyright (c) 2015年 student. All rights reserved.
//

#import "FirstOpenViewController.h"
#import "AppDelegate.h"

#define WinWidth [UIScreen mainScreen].bounds.size.width
#define WinHeight [UIScreen mainScreen].bounds.size.height

#define W(x) WinWidth*x/320.0  //屏幕适配，自动计算不同屏幕对应的x和y方向的坐标
#define H(y) WinHeight*y/568.0
@interface FirstOpenViewController ()<UIScrollViewDelegate>

@end

@implementation FirstOpenViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    UIApplication *app = [UIApplication sharedApplication];
    app.statusBarHidden = YES;
    [self addViewLayout];
}

/**
 *  为控制器添加视图布局
 */
-(void)addViewLayout{
    self.pageView.center = CGPointMake(WinWidth/2, WinHeight-80);
    self.showView.pagingEnabled = YES;
    self.showView.delegate = self;
    self.showView.showsHorizontalScrollIndicator = NO;
    self.showView.contentSize = CGSizeMake(WinWidth *3, WinHeight);
    self.showView.backgroundColor = [UIColor greenColor];
    UIImageView *imageV1 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, WinWidth, WinHeight)];
    imageV1.backgroundColor = [UIColor redColor];
    UIImageView *imageV2 = [[UIImageView alloc]initWithFrame:CGRectMake(WinWidth, 0, WinWidth, WinHeight)];
    imageV2.backgroundColor = [UIColor blueColor];
    UIImageView *imageV3 = [[UIImageView alloc]initWithFrame:CGRectMake(WinWidth*2, 0, WinWidth, WinHeight)];
    UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 60, 30)];
    imageV3.userInteractionEnabled = YES;
    btn.center = CGPointMake(WinWidth/2, WinHeight-120);
    [btn setTitle:@"Go" forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(gotoStartView) forControlEvents:UIControlEventTouchUpInside];
    btn.backgroundColor = [UIColor purpleColor];
    btn.layer.cornerRadius = 10;
    [imageV3 addSubview:btn];
    imageV3.backgroundColor = [UIColor greenColor];
    
    [self.showView addSubview:imageV1];
    [self.showView addSubview:imageV2];
    [self.showView addSubview:imageV3];
}


-(void)gotoStartView{
    AppDelegate *app = [UIApplication sharedApplication].delegate;
    [app gotoStartView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    CGFloat page = scrollView.contentOffset.x / WinWidth;
    self.pageView.currentPage = page;

}


@end
